<!--
 * @Author: lixb
 * @Date: 2020-08-19 10:29:30
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-09-24 11:03:36
 * @Descripttion: 薪享卡模块
-->
<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix" @click="goCareCard">
        <span class="modul-title">
          <img
            src="@/assets/img/welfareName.png"
            style="height: 25px;width: 25px;margin-right: 10px;"
          />
          <span>{{ welfareName }}</span>
        </span>
        <span type="text" class="title-right">本月已消费：￥{{ info.orderMonthAmount || 0 }}</span>
      </div>
      <div class="text item">
        <div class="balance">
          <p>
            {{ welfareName }}余额（元）
            <img src="@/assets/img/形状(3).png" />
          </p>
          <p class="money">{{ info.effectiveAmount || 0 }}</p>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
  import { findAdvanceDetail } from '@/api/home';
  import { getLocalData } from '@/utils/localStore';
  import { hasMenu } from '@/plugins/hasMenu';
  export default {
    data() {
      return {
        info: {},
      };
    },
    computed: {
      welfareName() {
        return getLocalData('welfareName');
      },
    },
    activated() {
      this.getInfo();
    },
    methods: {
      goCareCard() {
        if (hasMenu('WALFARE-FLGL-XXKFFJL')) {
          this.$router.push('/careCard/account');
        } else {
          this.$message.error('暂无操作权限！');
        }
      },
      getInfo() {
        findAdvanceDetail().then(res => {
          this.info = res.data || {};
        });
      },
    },
  };
</script>

<style lang="scss" scoped>
  .el-card.is-always-shadow {
    border-radius: 10px;
  }
  .modul-title * {
    font-weight: bold;
    font-size: 18px;
    display: inline-block;
    vertical-align: middle;
  }
  .clearfix {
    cursor: pointer;
  }
  .title-right {
    float: right;
    padding: 3px 0;
    font-size: 12px;
    color: #868686;
  }
  .balance {
    text-align: center;
    font-size: 12px;
    color: #333333;
    margin: auto;
    .money {
      font-size: 32px;
      font-weight: bold;
      color: #697bff;
    }
  }
</style>
